package com.itdct.onflow.core.controller


import com.itdct.onflow.core.context.BaseContext
import com.itdct.onflow.core.context.ContextHolder
import com.itdct.onflow.core.dto.BaseLoginDTO
import com.itdct.onflow.core.exception.CommonException
import org.springframework.stereotype.Controller

/**
 * @author Zhouwx
 * @date 2024/4/16 11:14:03
 * @version 1.0
 * @description
 */
@Controller
open class BaseController<AccountEntity : Any, LoginDTO : BaseLoginDTO<AccountEntity>> {

    protected fun getContext(): BaseContext<AccountEntity, LoginDTO> {
        val context = ContextHolder.getContext<AccountEntity, LoginDTO>()
        if (context == null) {
            throw CommonException("无法找到上下文")
        }
        return context
    }
}